package com.hetaozi.login.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hetaozi.login.entity.SysRolePermission;

import java.util.List;

import com.hetaozi.login.mapper.SysRolePermissionMapper;
import com.hetaozi.login.service.SysRolePermissionService;

/**
 * @email： wf520200@163.com
 * @date: 2021/11/11 15:51
 * 功能：
 * 描述：
 * @author： 吴帆
 **/
@Service
public class SysRolePermissionServiceImpl extends ServiceImpl<SysRolePermissionMapper, SysRolePermission> implements SysRolePermissionService {

    @Override
    public int updateBatch(List<SysRolePermission> list) {
        return baseMapper.updateBatch(list);
    }

    @Override
    public int batchInsert(List<SysRolePermission> list) {
        return baseMapper.batchInsert(list);
    }

    @Override
    public int insertOrUpdate(SysRolePermission record) {
        return baseMapper.insertOrUpdate(record);
    }

    @Override
    public int insertOrUpdateSelective(SysRolePermission record) {
        return baseMapper.insertOrUpdateSelective(record);
    }

    @Override
    public List<SysRolePermission> getSysRolePermissionByRoleIds(List<Long> roleIds) {
        if (roleIds != null && roleIds.size() > 0) {
            QueryWrapper<SysRolePermission> wrapper = new QueryWrapper<>();
            wrapper.in("role_id", roleIds);
            return baseMapper.selectList(wrapper);
        }
        return new ArrayList<>();
    }
}
